import request from '../request'
import { AdminGetUsersResponseData, UpdateResponseData } from './type'

enum API {
  ADMIN_GETUSERS_URL = '/auth/users', // 获取用户列表
  ADMIN_UPDATEUSER_URL = '/auth/user' // 更新用户权限
}

// 获取用户列表接口
export const reqAdminGetUsers = (
  params?: Partial<{
    pageNum: number
    pageSize: number
    keyword: string
  }>
) =>
  request<AdminGetUsersResponseData, any>({
    url: API.ADMIN_GETUSERS_URL,
    method: 'get',
    params
  })

// 更新用户权限接口
export const reqAdminUpdateUser = (data: { _id: string; isAdmin: boolean }) =>
  request<UpdateResponseData, any>({
    url: API.ADMIN_UPDATEUSER_URL,
    method: 'patch',
    data
  })
